/**
 * @author Modified by Abdul Khader Azeem
 *
 */

package edu.nus.iss.t5.jass.entity;

import java.util.Date;

import edu.nus.iss.t5.jass.exception.InvalidDataException;

public class JobAdvertisement extends Entity{
	
	
	public String baseCode;
	private String company;
	private String owner;
	public String jobDescription;
	private String technicalSkills;
	private String managementSkills;
	private int status;
	private Date postingDate;
	private Date expiryDate;
	private Date requiredStartDate;
	private int salaryMin;
	private int salaryMax;
	private String location;
	public String title;
	public int requiredWorkingExperience;
	private Date creationDate;
	private Date modifyDate;
	
	public JobAdvertisement(){
		
		this.company = null;
		this.owner = null;
		this.jobDescription = null;
		this.technicalSkills = null;
		this.managementSkills = null;
		this.status = 0;
		this.postingDate = null;
		this.expiryDate = null;
		this.requiredStartDate = null;
		this.salaryMin = 0;
		this.salaryMax = 0;
		this.location = null;
		this.title = null;
		this.requiredWorkingExperience = 0;
		this.creationDate = null;
		this.modifyDate = null;
	}
	
	public JobAdvertisement(String company, String owner, String jobDescription,
			String technicalSkills, String managementSkills, int status, Date postingDate, Date expiryDate, Date requiredStartDate,
			int salaryMin, int salaryMax, String location, String title, int requiredWorkingExperience, Date creationDate, Date modifyDate) throws InvalidDataException{
		    
		String error = null;
		if (company == null)
	        error = "company name not specified";
	    else if (owner == null)
	        error = "advertiser name not specified";
	    else if (jobDescription == null)
	        error = "jobDescription not specified";
	    else if (technicalSkills == null)
	        error = "technicalSkills for job not specified";		
	    else if (postingDate == null) 
	        error = "Invalid Posting Date";
        else if (requiredStartDate == null) 
            error = "Invalid StartDate";
        else if (location == null) 
            error = "Invalid Location";
        else if(title == null)
            error = "Invalid Position";
        else if(title == null)
            error = "Invalid Position";		
	    if (creationDate == null)
	    	error = "Invalid Creation Date";
	    if (error != null)
	    	throw new InvalidDataException(error);	    	
	     	  
		this.company = company;
		this.owner = owner;
		this.jobDescription = jobDescription;
		this.technicalSkills = technicalSkills;
		this.managementSkills = managementSkills;
		this.status = status;
		this.postingDate = postingDate;
		this.expiryDate = expiryDate;
		this.requiredStartDate = requiredStartDate;
		this.salaryMin = salaryMin;
		this.salaryMax = salaryMax;
		this.location = location;
		this.title = title;
		this.requiredWorkingExperience = requiredWorkingExperience;
		this.creationDate = creationDate;
		this.modifyDate = modifyDate;
	}
	
	public JobAdvertisement(JobAdvertisement ad){
		super(ad.getId());
		this.setKey(ad.getKey());
		this.company = ad.getCompany();
		this.owner = ad.getOwner();
		this.jobDescription = ad.getJobDescription();
		this.technicalSkills = ad.getTechnicalSkills();
		this.managementSkills = ad.getManagementSkills();
		this.status = ad.getStatus();
		this.postingDate = ad.getPostingDate();
		this.expiryDate = ad.getExpiryDate();
		this.requiredStartDate = ad.getRequiredStartDate();
		this.salaryMin = ad.getSalaryMin();
		this.salaryMax = ad.getSalaryMax();
		this.location = ad.getLocation();
		this.title = ad.getTitle();
		this.requiredWorkingExperience = ad.getRequiredWorkingExperience();
		this.creationDate = ad.getCreationDate();
		this.modifyDate = ad.getModifyDate();
	}
		
	
		// TODO Auto-generated constructor stub
	

	public void setBaseCode(String baseCode) {
		super.setId(baseCode);
	}
	public String getBaseCode() {
		return super.getId();
	}
	public void setCompany(String company) {
		this.company = company;
	}
	public String getCompany() {
		return company;
	}
	public String toStringStatus(){
    	if (status == 0) return "Active";
    	if (status == 1) return "In-Active";
    	return "N/A";
	}
	public void setJobDescription(String jobDescription) {
		this.jobDescription = jobDescription;
	}
	public String getJobDescription() {
		if(jobDescription==null)
			return "";
		return jobDescription;
	}
	
	public Date getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}

	public String getManagementSkills() {
		return managementSkills;
	}

	public void setManagementSkills(String managementSkills) {
		this.managementSkills = managementSkills;
	}

	public Date getModifyDate() {
		return modifyDate;
	}

	public void setModifyDate(Date modifyDate) {
		this.modifyDate = modifyDate;
	}

	public String getOwner() {
		return owner;
	}

	public void setOwner(String owner) {
		this.owner = owner;
	}

	public int getRequiredWorkingExperience() {
		return requiredWorkingExperience;
	}

	public void setRequiredWorkingExperience(int requiredWorkingExperience) {
		this.requiredWorkingExperience = requiredWorkingExperience;
	}

	public String getTechnicalSkills() {
		if(technicalSkills==null)
			return "";
		return technicalSkills;
	}

	public void setTechnicalSkills(String technicalSkills) {
		this.technicalSkills = technicalSkills;
	}

	
	public void setStatus(int status) {
		this.status = status;
	}
	public int getStatus() {
		return status;
	}
	public void setPostingDate(Date postingDate) {
		this.postingDate = postingDate;
	}
	public Date getPostingDate() {
		return postingDate;
	}
	public void setExpiryDate(Date expiryDate) {
		this.expiryDate = expiryDate;
	}
	public Date getExpiryDate() {
		return expiryDate;
	}
	public void setRequiredStartDate(Date requiredStartDate) {
		this.requiredStartDate = requiredStartDate;
	}
	public Date getRequiredStartDate() {
		return requiredStartDate;
	}
	public void setSalaryMin(int salaryMin) {
		this.salaryMin = salaryMin;
	}
	public int getSalaryMin() {
		return salaryMin;
	}
	public void setSalaryMax(int salaryMax) {
		this.salaryMax = salaryMax;
	}
	public int getSalaryMax() {
		return salaryMax;
	}
	public void setLocation(String location) {
		this.location = location;
	}
	public String getLocation() {
		if(location==null)
			return "";
		return location;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getTitle() {
		if(title==null)
			return "";
		return title;
	}
}
